<?php

namespace KGK\StoreBundle\Extension;

use Symfony\Bridge\Doctrine\RegistryInterface;

class CategorieExtension extends \Twig_Extension
{
    protected $doctrine;

    public function __construct(RegistryInterface $doctrine)
    {
        $this->doctrine = $doctrine;
    }

    public function getCategories()
    {
        $categories = $this->doctrine
            ->getRepository('KGKStoreBundle:Categorie')
            ->findAll();
        return $categories;
    }

    public function getName()
    {
        return 'categories.twig';
    }

    public function getFunctions()
    {
        return array(
            'getCategories' => new \Twig_Function_Method($this, 'getCategories'));
    }

}